/*
 * Copyright (c) 2017. 杭州端点网络科技有限公司.  All rights reserved.
 */

package com.jiantong.web.core.component;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * 如果用到terminus的msg模块发短信需要把swagger配置关闭
 * 因为这个配置会导致短信外部属性配置失效
 *
 * @author : panxin
 */
@Configuration
public class SwaggerConfiguration {

    @Bean
    public Docket iguazuApis() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("djt")
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.regex("/api/.*"))
                .build()
                .pathMapping("/")
                .apiInfo(apiInfo())
                .useDefaultResponseMessages(false);
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("djt api")
                .description("djt api")
                .version("1.0.0")
                .contact(new Contact("djt", "djt.com", ""))
                .build();
    }

}
